<?php
/**
 * Timestamp listener
 *
 * PHP version 5
 *
 * @category   Web
 * @package    Data2People
 * @subpackage Models
 * @author     Mike Bevz <mike.bevz@data2people>
 * @copyright  2007-2008 (c) Mike Bevz
 * @license    The BSD License http://data2people.com/license.txt
 * @version    SVN: $Id: TimestampListener.php 13 2008-12-01 16:16:50Z michael.bevz $
 *
 *
 */
/**
 * Includes
 */
require_once 'Doctrine/Record/Listener.php';

/**
 * Timestamp listener class
 *
 * PHP version 5
 *
 * @category   Web
 * @package    Data2People
 * @subpackage Models
 * @author     Mike Bevz <mike.bevz@data2people>
 * @copyright  2007-2008 (c) Mike Bevz
 * @license    The BSD License http://data2people.com/license.txt
 * @version    SVN: $Id: TimestampListener.php 13 2008-12-01 16:16:50Z michael.bevz $
 *
 *
 */
class TimestampListener extends Doctrine_Record_Listener
{
    /**
     * Performs before INSERT
     *
     * @param Doctrine_Event $event Event
     *
     * @return void
     */
    public function preInsert(Doctrine_Event $event)
    {
        $event->getInvoker()->created_at = date('Y-m-d H:i:s', time());
    }

    /**
     * Performs before UPDATE
     *
     * @param Doctrine_Event $event Event
     *
     * @return void
     */
    public function preUpdate(Doctrine_Event $event)
    {
        $event->getInvoker()->updated_at = date('Y-m-d H:i:s', time());
    }
}
